package com.zhang.gmall.utils;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;
import java.time.temporal.ValueRange;
import java.util.ArrayList;
import java.util.List;

/**
 * @title:
 * @author: zhang
 * @date: 2022/3/26 22:23
 */
public class KeyWordUtil {
    public static List<String> splitKeyWord(String keyWord) throws IOException {
        ArrayList<String> words = new ArrayList<>();
        IKSegmenter ikSegmenter = new IKSegmenter(new StringReader(keyWord), false);
        Lexeme next = ikSegmenter.next();
        while (next != null){
            String word = next.getLexemeText();
            words.add(word);
            next = ikSegmenter.next();
        }

        return words;
    }

    public static void main(String[] args) throws IOException {
        System.out.println(splitKeyWord("大数据"));
    }
}
